{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Random Sampling\n",
    "==========================\n",
    "\n",
    "Credits: Forked from [CompStats](https://github.com/AllenDowney/CompStats) by Allen Downey.  License: [Creative Commons Attribution 4.0 International](http://creativecommons.org/licenses/by/4.0/)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from __future__ import print_function, division\n",
    "\n",
    "import numpy\n",
    "import scipy.stats\n",
    "\n",
    "import matplotlib.pyplot as pyplot\n",
    "\n",
    "from IPython.html.widgets import interact, fixed\n",
    "from IPython.html import widgets\n",
    "\n",
    "# seed the random number generator so we all get the same results\n",
    "numpy.random.seed(18)\n",
    "\n",
    "# some nicer colors from http://colorbrewer2.org/\n",
    "COLOR1 = '#7fc97f'\n",
    "COLOR2 = '#beaed4'\n",
    "COLOR3 = '#fdc086'\n",
    "COLOR4 = '#ffff99'\n",
    "COLOR5 = '#386cb0'\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Part One\n",
    "========\n",
    "\n",
    "Suppose we want to estimate the average weight of men and women in the U.S.\n",
    "\n",
    "And we want to quantify the uncertainty of the estimate.\n",
    "\n",
    "One approach is to simulate many experiments and see how much the results vary from one experiment to the next.\n",
    "\n",
    "I'll start with the unrealistic assumption that we know the actual distribution of weights in the population.  Then I'll show how to solve the problem without that assumption.\n",
    "\n",
    "Based on data from the [BRFSS](http://www.cdc.gov/brfss/), I found that the distribution of weight in kg for women in the U.S. is well modeled by a lognormal distribution with the following parameters:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(72.697645732966876, 16.944043048498038)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "weight = scipy.stats.lognorm(0.23, 0, 70.8)\n",
    "weight.mean(), weight.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's what that distribution looks like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZQAAAEPCAYAAABlZDIgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4XPV97/H3bNp3S7I2G8nCeMGAF2xMIFhsLSUNkCYN\npaFsaUOeXtLetPeWpPe5T5x773ObtE/alKYlpE0TB3ohEFJqmrAFUELA2MY2XrBlS94tWbJs7Ysl\njWbuH+doNGdGM9YyozPL55XMo/P7zTkzX2N5vvNbzu8HIiIiIiIiIiIiIiIiIiIiIiIiIiIiInNy\nB9AENAOPRzjnCfP5vcAasy4L2A58CBwE/iro/BLgDeAI8DpQFPOoRUQkobiAFqAW8GAkhxUh59wJ\n/Nw8vg54P+i5HPOn26y/wSz/NfAX5vHjwDdiGbSIiCSe64FXg8pfMR/BvgvcG1RuAhaGnJMD7ARW\nTnFOhVkWERGbOeP42tXA6aDyGbPuUufUmMcujFZNB/A2RtcXGMmkwzzuIDwBiYiIDeKZUPzTPM8R\n4bpxYDVGgrkJaIjwHtN9HxERiSN3HF+7FVgUVF6E0QKJdk6NWResF/gZsA5oxGiVVADtQCVwbqo3\nr6+v9x89enSWoYuIpKWjwOWzvTieLZQPgKUYg/IZGGMlW0PO2Qo8YB5vBHowEkYpk7O3soHbMbq/\nJq550Dx+EHhpqjc/evQofr8/KR9f+9rXbI9B8dsfh+JPzkcyxw/Uz+VDP54tFC/wGPAaxnjI94FD\nwKPm809hzPC6E2M22CDwsPlcJbAFI+E5gaeBN83nvgE8D3weOAF8No5/BhERmaZ4JhSAV8xHsKdC\nyo9Ncd1+YG2E1+wCbptjXCIiEmPx7PKSWWpoaLA7hDlR/PZS/PZK9vjnInSGVSrxm32CIi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PGGe80OMzbvA6B5rNo83Mbn/TagKrHtWPIiRoD5lvvbErob/CdxrHj+K\nNaHUYSQ3kXmhFoqIsY/LOiAfY3HCbRgrEd+IkWA2Yuxe9x5Ga+IBYHHQ9Q5gA0bS6cFYufgFJpcx\n9zO5YOMhJvcribbM+WXA2ZD3uAVj7bE7gV6zfqP5XmCs0xTsLMZKuCLzwm13ACIJYAyjdfEQRtLY\nh/HhfTnGoniXY2y8FW28I3SMIzRZjEZ5LpLg8/wY3WV1wDKMrrfpXJ+I+29IilILRcTwDvDfMFoZ\n7wBfxGi5gNFtdAPGeAUY4ydLg671Y6y2vInJLq9Pc+kP836MVtFUTjK5xwkYyeEkxrjKjzBaTGB0\nz33GPP69kNeoNK8RmRdKKCKGdzA+wLdhbFA1bNaBscXxQxhdSnsxWjHLQq5vA/4vxn4Rv8Zo8fQG\nPe+f4ngvMI6x9ULooHw7RmLKCbrGjzHo/zmMbq46jB0n/8x8jfqQ99yAMd4iIiJJZmLmlxtjhtXd\nc3y9zUwOuEeSHXT8e8C/B5X/DVgzxxhERMQGf4MxaH8I6+6hs1XGpW9OvBGjdbIXYwrzErM++KZI\nEREREREREREREREREREREREREREREZFY+P86jD7vAkkpbAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d9ead90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "xs = numpy.linspace(20, 160, 100)\n",
    "ys = weight.pdf(xs)\n",
    "pyplot.plot(xs, ys, linewidth=4, color=COLOR1)\n",
    "pyplot.xlabel('weight (kg)')\n",
    "pyplot.ylabel('PDF')\n",
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`make_sample` draws a random sample from this distribution.  The result is a NumPy array."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def make_sample(n=100):\n",
    "    sample = weight.rvs(n)\n",
    "    return sample"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's an example with `n=100`.  The mean and std of the sample are close to the mean and std of the population, but not exact."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(76.308293640077437, 19.995558735561865)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample = make_sample(n=100)\n",
    "sample.mean(), sample.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We want to estimate the average weight in the population, so the \"sample statistic\" we'll use is the mean:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def sample_stat(sample):\n",
    "    return sample.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "One iteration of \"the experiment\" is to collect a sample of 100 women and compute their average weight.\n",
    "\n",
    "We can simulate running this experiment many times, and collect a list of sample statistics.  The result is a NumPy array."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def compute_sample_statistics(n=100, iters=1000):\n",
    "    stats = [sample_stat(make_sample(n)) for i in range(iters)]\n",
    "    return numpy.array(stats)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The next line runs the simulation 1000 times and puts the results in\n",
    "`sample_means`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "sample_means = compute_sample_statistics(n=100, iters=1000)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's look at the distribution of the sample means.  This distribution shows how much the results vary from one experiment to the next.\n",
    "\n",
    "Remember that this distribution is not the same as the distribution of weight in the population.  This is the distribution of results across repeated imaginary experiments."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEPCAYAAACp/QjLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE+BJREFUeJzt3X2UXHV9x/H35AHLU7JJxRCSaBBJS5RKFGMqWqaUpuHY\nmtAWkBYbq8djT+Th1NpqtEc2teVgFUtthPZUwSCaNoqmwYcW5DCn2BqjyENCiCaRKBtDgprdhWpt\nCNs/fr9hb+Y3u5lN5t67M3m/zpkzd37zcL+/fbif+zS/C5IkSZIkSZIkSZIkSZIkSVLXmQPcCzwC\nbAGuju29QB/wQLxdlHnPSmA7sA1YXFShkqTinAqcE6dPAr4DnAVcC7yzyevnAw8Ck4G5wA5gQu5V\nSpISeS58nyAs7AGeBh4FZsXHlSavXwqsBQ4AuwjhsDDH+iRJIyhqzXwusADYGB9fBTwEfALoiW2n\nEXY31fUxHCaSpAIVEQ4nAZ8DriFsQdwMnE7Y5bQHuGGU9w7lXp0kKTEp58+fDNwB3A6sj237Ms9/\nHLgzTu8mHMSumx3bDnHGGWcM7dy5s/2VSlJ32wm8pNUX57nlUCHsNtoK3Jhpn5mZvhjYHKc3AG8E\njiNsWZwJbGr80J07dzI0NNS1t2uvvbb0Guyb/bN/3XcDzhjLAjzPLYfzgCuAhwmnrAK8F7icsEtp\nCHgMeHt8biuwLt4/A6zA3UqSVIo8w+FrNN8y+coo77ku3qSuNbVnGoMD/YXMa8rUHgb69xcyL3WX\nvI85aIyq1WrZJeSmm/sGrfdvcKCfRVeuP/wL22Dj6mVt+yx/f8eWZt83GO+G4v4zqSNVKpVCw8H/\nF0H4u2MMy3y/gSxJShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4SBJ\nShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4SBJShgOkqSE4S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R/q9mxnluic99Pt5/G/jdJvN9EeGKXXVDhK2sA4Q1932Ege9+SPEL6h8CLy54niqZ4aAibSes\nIb8e+GvgHsJlQz9GWODuJqwhZ4e6/nm8fzYzXX9c//sdyrRXGh7X3U1rF95pZX5rgPc2vO90wrWV\nzyUMhXwrzftxkOb/d0MM7/+v+7/MdPZ99wEnNfmMdxF+piPZzaEXeJlN2GLYHaez7bszj0f6maqL\nuVtJRZpJGMb604QtiAUML0B/TFjgXdL8raN6IWHrAEIA3Jd5bohwZa/zgDNi24nAmUcwnyHCwvf3\nGb6AyvQ4/5OB/yFsycwgXKN3LL7P8HUuDud1hJ9d461ZMGQDZwPwRsKW0+mEn8EmwpbPIOH4Q4Vw\ndlJ2KPWZhGMUOoa45aAinQ18iLAWfoCwP3+AcInULYSF1DdGeO8QI6+9fgd4B+EA7iOE/fpZPyIc\nM1hLOPAL4fjA9lFqHWl+jwJ/SRhufELsxwrCQvYBwsHgx2l+TenRPvch0gPVR7q2fjHwUcKxli/F\nui4iHLBfF++fiXXX57EC+CRhN9mXOfQiMQtpfpxEksatuYSznLrBJwlr7+PJFIbPoJKkjjGXcKC7\nG7yMcKxiPLmacOquJEmSJEmSJEmSJEmSJEmSJBXh/wEpLq6DT7+D0wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d915710>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "pyplot.hist(sample_means, color=COLOR5)\n",
    "pyplot.xlabel('sample mean (n=100)')\n",
    "pyplot.ylabel('count')\n",
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The mean of the sample means is close to the actual population mean, which is nice, but not actually the important part."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "72.652052080657413"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sample_means.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The standard deviation of the sample means quantifies the variability from one experiment to the next, and reflects the precision of the estimate.\n",
    "\n",
    "This quantity is called the \"standard error\"."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.6355262477017491"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "std_err = sample_means.std()\n",
    "std_err"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also use the distribution of sample means to compute a \"90% confidence interval\", which contains 90% of the experimental results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 69.92149384,  75.40866638])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conf_int = numpy.percentile(sample_means, [5, 95])\n",
    "conf_int"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following function takes an array of sample statistics and prints the SE and CI:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def summarize_sampling_distribution(sample_stats):\n",
    "    print('SE', sample_stats.std())\n",
    "    print('90% CI', numpy.percentile(sample_stats, [5, 95]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's what that looks like:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.6355262477\n",
      "90% CI [ 69.92149384  75.40866638]\n"
     ]
    }
   ],
   "source": [
    "summarize_sampling_distribution(sample_means)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we'd like to see what happens as we vary the sample size, `n`.  The following function takes `n`, runs 1000 simulated experiments, and summarizes the results."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def plot_sample_stats(n, xlim=None):\n",
    "    sample_stats = compute_sample_statistics(n, iters=1000)\n",
    "    summarize_sampling_distribution(sample_stats)\n",
    "    pyplot.hist(sample_stats, color=COLOR2)\n",
    "    pyplot.xlabel('sample statistic')\n",
    "    pyplot.xlim(xlim)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's a test run with `n=100`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.71202891175\n",
      "90% CI [ 69.96057332  75.58582662]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEPCAYAAABIut/fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEdZJREFUeJzt3X+Q1PV9x/HneqiNknh3MQFEIhY1IzGtWEPt6IwLQylO\nO6Jm/NWakqlNneCI0zRNpJ2Gu0nGmrYxpG10Wn+VRiXBqBTamPHndjQmYioIiCggRKEKUe5MnGkS\nxOsfn896X5e9u9293dvdzz0fM9/Z7372u9/vm2O/r/vc5/vd7xckSZIkSZIkSZIkSZIkSZLGpWnA\nY8BzwGZgSWzvAXYD6+N0XuY9S4FtwFZg/lgVKkmqzmTg9Dg/EXgBOBVYBnyuzPIzgQ3A4cB0YDtw\nWMOrlCQdYqTwfY0Q2ABvAc8DU+PzXJnlFwIrgQPALkLAzx51lZKkqlXTu54OzAJ+FJ9fAzwL3AZ0\nxrbjCEM3RbsZ/IUgSRpDlQb8ROC7wLWEnvzNwImE4ZtXga8N896B0RQoSarNhAqWORy4F7gTWB3b\n9mVevxVYG+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Mv4+E5mvvi8eCwpO86eo/y4+0Nx27OAjwGfKbPM78daziAMC3WUWeafgH+M\ntV7F8L3rYoBXsl6pbgx4NcMUwmV+7yIMbcxiMMzfIPReLy7/1mF9hNBLh3CXp8czrw0Q/jo4m3Az\nBQjj7yeXrCPH4L07ryNcPXQi4UBo9qqEHyAMFUG4Nn1R6XLVrre47FuEsfniEM2ROESjKhnwaoaP\nE8aX1xMOrH6FcOOFWwjDL9+Pr5cz3BkxLwBXEw6yHgPcXPL664QwXkk40Pkk8NGSZToIl8PdSDiA\n+o1Y21rCnYCyB0PvAX5MuGNQsabics8wOEQ0UMF6S5eHcLrkkljrDxi8F6ckjSvTCUM+kiJ78ErJ\naM91lyRJkiRJkiRJkiRJkiRJktT6/h+vgGLmrLQN+wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d9eaf90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_sample_stats(100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can use `interact` to run `plot_sample_stats` with different values of `n`.  Note: `xlim` sets the limits of the x-axis so the figure doesn't get rescaled as we vary `n`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.71314776815\n",
      "90% CI [ 69.99274896  75.65943185]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEPCAYAAABIut/fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEaNJREFUeJzt3X+QXeVdx/H3ZRMoSSjZFZqEkHYxQCVEJVVjHWC4zcRM\nUIdAmPJD0WCxg9IhTKtTiDM2uxYpdQTRKoyWH5OWEpu2IQaddgg/LqXWQisJSQiBJJIxSWGhklhw\n1IZl/eN5Lnu4ubt7f+y99+y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Xj+sF3mZ4uuMehoOyHPAn\nEe7MVw7+G4E/qVLfAcLtALK1VX7RQvaj7L8H/MUI+2XXa3nd7PpThBuhQfhvPR6pDu36wg8payvw\nq4RvzTmP8GURAIsIo+KtcXle5piN8Xl7fAwAPyF8i1D5Ptn7GJ7quD++dlmBcDOseYQR/Gbgdwg3\ncqpW3wOE290OVrxG2RzCPUu2An9UUetIX8hQy+uWTQNOAf4xrv8E+J8RXleqyoBXJ+wCFhCmYm4m\njKKPI9xe9lLg5whfZvKezDH/F5/fziyX18vnkrLz7AWqz7tviu+9ADibd38JTdmvx1o+RJgW6qqy\nzxeAv461Xsvoo+tygNfyutK4MeDVCbMIX0X2FcLUxgKGw/w/CaPXj1Y/dFTvJ4zSAX4TeDKzbYjw\nr4NzCV9OAWH+/YyK1yjE1ykBNxHuKjqNcCI0e8fJ9xKmigCuzrRX7lfv65b3fZMwN1+eojkOp2hU\nJwNenfCzhPnlzYQTqzcTvlv2i4Tpl2/F7dWMdkXMC8AnCCdZTwTuqtj+I0IYryWc6Pwu8MGKfbqA\nLxOmU54B/irW9hDh/tvZk6FfI3zjzmuZmsr7PcPwFNFQDa9buT+EyyVXxlr/BW8NK+ko1Us+vkxC\nyg1H8EpJs9e6S5IkSZIkSZIkSZIkSZIkScq//wcqt2WnGugEMAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d804810>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def sample_stat(sample):\n",
    "    return sample.mean()\n",
    "\n",
    "slider = widgets.IntSliderWidget(min=10, max=1000, value=100)\n",
    "interact(plot_sample_stats, n=slider, xlim=fixed([55, 95]))\n",
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This framework works with any other quantity we want to estimate.  By changing `sample_stat`, you can compute the SE and CI for any sample statistic.\n",
    "\n",
    "As an exercise, fill in `sample_stat` below with any of these statistics:\n",
    "\n",
    "* Standard deviation of the sample.\n",
    "* Coefficient of variation, which is the sample standard deviation divided by the sample standard mean.\n",
    "* Min or Max\n",
    "* Median (which is the 50th percentile)\n",
    "* 10th or 90th percentile.\n",
    "* Interquartile range (IQR), which is the difference between the 75th and 25th percentiles.\n",
    "\n",
    "NumPy array methods you might find useful include `std`, `min`, `max`, and `percentile`.\n",
    "Depending on the results, you might want to adjust `xlim`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.67195986148\n",
      "90% CI [ 69.82954731  75.32184298]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEPCAYAAACjjWTcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEfxJREFUeJzt3XuMnNV9h/FnWGMSoLF3ResLdmIXTIWhDZCG0pKKwTIO\nqBEmVNxSWjelERIo0PQCGClht4kIiQJNb6CWAHIhuHGAuEZRKAYzFblwSWIuxjjYDlaxi9cE7ARK\nW/Cy/eOc2RmPd3bHM7M7y/6ej/Rq3vfM+75z9sB85/i8N5AkSZIkSZIkSZIkSZIkSVKbvAd4HHgK\n2Ah8MZf3AGuBF4AHgelV2ywHNgObgCXjVlNJUksOza9TgMeAjwBfBq7K5VcDN+T5haQfhoOBecAW\n4KDxqqgkqXWHAk8Cx5F67TNy+cy8DKlXf3XVNg8Ap4xXBSVJw2uk130QqbfeDzwCPEcK+v78fj+V\n4J8NbK/adjtwZFtqKklq2pQG1nkHOAGYBvw7cHrN+4N5qmek9yRJ46CRsC/7OfBt4EOk3vxMYCcw\nC9iV19kBzK3aZk4u28dRRx01uHXr1mbqK0mRbQWObmbD0YZxjqByps17gTOA9cAaYFkuXwaszvNr\ngAuBqcB8YAHwxH613bqVwcFBp8FBrrvuuo7XYaJMtoVtYVuMPAFHNRP0MHrPfhawgvSjcBBwJ/Bw\nDvx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X1Czj0LeT4n0EJFpuT6vA79U\ntd77SMNJAH9cVV673oHut7zuG6Sx/PIwziE4jKMWGPbqhF8njUevJx2U/QLwc1JvfgPpeZqP19l2\npDNrfgJcTjpAOw24peb9n5GCeSXpIOn3gV+rWaeL9CCVZ0gHX/821+1+4OPseyD1m6TnNLxSVafy\nej+mMow02MB+a9eHdArmFbmu3yPW4/gkaVjz2PdBzZKq2LPXZBL12aSSJEmSJEmSJEmSJEmSJEmS\n2uf/Ae9uXzO2YPMxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d775990>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def sample_stat(sample):\n",
    "    # TODO: replace the following line with another sample statistic\n",
    "    return sample.mean()\n",
    "\n",
    "slider = widgets.IntSliderWidget(min=10, max=1000, value=100)\n",
    "interact(plot_sample_stats, n=slider, xlim=fixed([0, 100]))\n",
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Part Two\n",
    "========\n",
    "\n",
    "So far we have shown that if we know the actual distribution of the population, we can compute the sampling distribution for any sample statistic, and from that we can compute SE and CI.\n",
    "\n",
    "But in real life we don't know the actual distribution of the population.  If we did, we wouldn't need to estimate it!\n",
    "\n",
    "In real life, we use the sample to build a model of the population distribution, then use the model to generate the sampling distribution.  A simple and popular way to do that is \"resampling,\" which means we use the sample itself as a model of the population distribution and draw samples from it.\n",
    "\n",
    "Before we go on, I want to collect some of the code from Part One and organize it as a class.  This class represents a framework for computing sampling distributions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class Resampler(object):\n",
    "    \"\"\"Represents a framework for computing sampling distributions.\"\"\"\n",
    "    \n",
    "    def __init__(self, sample, xlim=None):\n",
    "        \"\"\"Stores the actual sample.\"\"\"\n",
    "        self.sample = sample\n",
    "        self.n = len(sample)\n",
    "        self.xlim = xlim\n",
    "        \n",
    "    def resample(self):\n",
    "        \"\"\"Generates a new sample by choosing from the original\n",
    "        sample with replacement.\n",
    "        \"\"\"\n",
    "        new_sample = numpy.random.choice(self.sample, self.n, replace=True)\n",
    "        return new_sample\n",
    "    \n",
    "    def sample_stat(self, sample):\n",
    "        \"\"\"Computes a sample statistic using the original sample or a\n",
    "        simulated sample.\n",
    "        \"\"\"\n",
    "        return sample.mean()\n",
    "    \n",
    "    def compute_sample_statistics(self, iters=1000):\n",
    "        \"\"\"Simulates many experiments and collects the resulting sample\n",
    "        statistics.\n",
    "        \"\"\"\n",
    "        stats = [self.sample_stat(self.resample()) for i in range(iters)]\n",
    "        return numpy.array(stats)\n",
    "    \n",
    "    def plot_sample_stats(self):\n",
    "        \"\"\"Runs simulated experiments and summarizes the results.\n",
    "        \"\"\"\n",
    "        sample_stats = self.compute_sample_statistics()\n",
    "        summarize_sampling_distribution(sample_stats)\n",
    "        pyplot.hist(sample_stats, color=COLOR2)\n",
    "        pyplot.xlabel('sample statistic')\n",
    "        pyplot.xlim(self.xlim)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following function instantiates a `Resampler` and runs it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def plot_resampled_stats(n=100):\n",
    "    sample = weight.rvs(n)\n",
    "    resampler = Resampler(sample, xlim=[55, 95])\n",
    "    resampler.plot_sample_stats()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's a test run with `n=100`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.72606450921\n",
      "90% CI [ 71.35648645  76.82647135]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEPCAYAAABIut/fAAAABHNCSVQICAgIfA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X386eDP064Y47b2RqKu/3In1TRL11vG7l/hA+Lrks1vrveGlYSUepTvJxMwkp\nNxzBKyXD/ay7JEmSJEmSJEmSJEmSJEmSpPz7f8dcrFjNGODdAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f2974281c50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_resampled_stats(100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can use `plot_resampled_stats` in an interaction:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.67407589545\n",
      "90% CI [ 69.60129748  75.13161693]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEPCAYAAABIut/fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEqdJREFUeJzt3X2MXNV9h/FnWGPA0ODdQvyerGsgjXFbTBqXClAGy7FM\nW2EwCi8pravQiJYIo7QV4EoNu0AJiQpJ30BteJEDwY2TGNc0KsXGTEqS8pLgV4yD7WLVdmFNgp2A\n1DZgtn+cM97r8axnZndm5+7x85Gu5s659878cjz57uHMnXtBkiRJkiRJkiRJkiRJkiTpmHQi8Byw\nAdgKfD62dwFrgFeAJ4HxmWOWAtuBbcD8EatUktSwcfFxDPAscAHwReCm2H4zcFdcn0n4Y3A80A3s\nAI4bqUIlSUMzDngBOJswOp8Q2yfG5xBG7zdnjnkCOG+kCpQkDahndH0cYVTeBzwNvEQI9764vY+B\nsJ8M7MkcuweY0pRKJUkNGVPHPu8B5wCnAv8GXFSxvT8ugznaNklSi9QT8GU/Bb4NfIQwap8IvA5M\nAvbFffYC0zLHTI1th5kxY0b/zp07h1KvJB3LdgJn1LtzrSma0xg4Q+Yk4OPAemA1sDi2LwZWxfXV\nwFX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IPwUfnc8rht4j4HpjgcYCMpywJ9GuDJfOfhvBv6iSn17CZcDyNZWeaOF7E/Z\n/xD4q0H2yz6v53Wzz58jXAgNwv/Wk5AaMFI3/JCyNgEfJ9w15wLCzSIA5hJGxZvi+szMMavj45a4\n9AE/J9xFqHyd7N0MTHU8El+7rEC4GNZMwgh+PfD7hAs5VavvUcLlbg9WvEbZNMI1SzYBf1ZR62A3\nZKjndctOASYD/xyf/xz4n0FeV6rKgFc7bAdmE6Zi7iCMok8gXF72cuBXCTczOTFzzP/Fx/cy6+Xn\n5e+SsvPsBarPu6+J7z0bOJvDb0JT9tuxlnMJ00IdVfb5W+BvYq3XcfTRdTnA63ldqWkMeLXDJMKt\nyL5GmNqYzUCY/4Qwev1E9UOP6gOEUTrAJ4FnMtv6Cf91cD7h5hQQ5t/PrHiNQnydEnAL4aqipxC+\nCM1ecfJ9hKkigD/ItFfu1+jrlvd9mzA3X56iOQGnaNQgA17t8CuE+eX1hC9W7yDcW/YrhOmXJ+L2\nao52RsyPgM8QvmQ9FbivYvuPCWG8nPBF5/eBD1Xs0wE8TJhOeRH461jb44Trb2e/DP0G4Y47b2Rq\nKu/3IgNTRP11vG7l/hBOl1wSa/0eXhpW0jGqm3zcTELKDUfwSslwz3WXJEmSJEmSJEmSJEmSJEmS\nlH//D7GQuCrLS9UsAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d796cd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "slider = widgets.IntSliderWidget(min=10, max=1000, value=100)\n",
    "interact(plot_resampled_stats, n=slider, xlim=fixed([1, 15]))\n",
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Exercise: write a new class called `StdResampler` that inherits from `Resampler` and overrides `sample_stat` so it computes the standard deviation of the resampled data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class StdResampler(Resampler):   \n",
    "    \"\"\"Computes the sampling distribution of the standard deviation.\"\"\"\n",
    "    \n",
    "    def sample_stat(self, sample):\n",
    "        \"\"\"Computes a sample statistic using the original sample or a\n",
    "        simulated sample.\n",
    "        \"\"\"\n",
    "        return sample.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Test your code using the cell below:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.30056137605\n",
      "90% CI [ 13.70615766  18.05008376]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEPCAYAAACjjWTcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEMFJREFUeJzt3X+wXOVdx/H3chNQCU3uHTS/22AIDikqQY1VdNhmYgwj\nQwAtPxSNigwzdAhatRBUcu/YQdopFH/BVPkxsZTYFNKYjNMOKWEdsBasDSSXEEhSMpKY3MSSW8BB\nG8L1j+fZ7GZzf2x2994N9/t+zZzZc549e85zH9jPPnnOL5AkSZIkSZIkSZIkSZIkSVKLzAaeBl4C\neoEVubwb2AtsydOlVZ9ZCewEdgBLxqqikqTGTQMuzPOTgFeA84FVwCcGWX8+8AIwEZgD7AJOG/Va\nSpKGNVIQHyCFN8DbwMvAzLxcGGT9ZcAa4AiwhxT2C5uupSSpKSfT654DLAC+mZdvAV4EHgKm5LIZ\npOGdsr1UfhwkSW1Sb9hPAh4HbiX18B8AziEN8ewH7hnmswPNVFCS1LwJdawzEXgCeBRYn8sOVr3/\nILAxz+8jHdQtm5XLjjN37tyB3bt3n3RlJSm43cC5jXxwpJ59gTRMsx24r6p8etX8lcC2PL8BuBY4\nndTznwc8f0Jtd+9mYGDAaWCAVatWtb0Op8pkW9gWtsXwEzC3kaCHkXv2FwPXA1tJp1gC3AFcRxrC\nGQBe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nW7y+JL1v\nnAn8M+lq4m3Ax3L5naRLvrdxfOiVgHtJV5m+DPwM8BXSVYV/nteZQ7qS8FHSJfZfJl12D+mhMRfl\n+SWk+6/8B7A216XWCtJVnC+SHqDxIWA/6R42W0hXQ18GfJN0p8pNwI/kOtSu1w384Ulst3r9c0lX\nT76Q6/ujg9RVkk5Zvwr8XdXyB/JrZ1XZP5ACFVJY/0WeX0G6pHwq6b4gr+fPzSHdjqI8JPIQldAs\nh/3ZwL9Q+RG4DfizQeq3j3SZfnXdVpEetlJWfdn67wGfHWK96uV6tlu9/BywLM+fXlVv6aSdMk82\nUShbSQ+luJvUm30zly8i9Za35vn5VZ8p3z+nN099pHuIfIfK3f9epzIc8mjedlmBdJOt+aSe/Rbg\nt4APDlG/x4DfAI7WbKNsNuleJVuBP6qp61C3ba5nu2WTSLf5/ae8/H3gnSG2K43IsFc77KTy+LVP\nkXrXZwB/S+r1/wTpIR4/UPWZ/8uv71XNl5fLx56qx+ULDD5OvynvewHwYeDGQdb5lVyXi0hDRx2D\nrPPXwF/lut7E8L3ucpjXs11pVBj2aofpwP+Snj/7WVLwloP9u6Re7ccG/+iwPkjl0Wy/DjxT9d4A\n6V8NF5MekgFpvH5ezTYKeTsl0kNEJuf6vAWcVbXeB0jDSQC/XVVeu97Jbre87tuksfzyMM4ZOIyj\nJhj2aocfJ41HbyEdlP0U8D1Sb76X9DzN54b47HBn1rwCfJx0gHYy8EDN+/9NCuY1pIOk3wB+rGad\nDtKDVLaSDr7+Za7bRuBKjj+Q+mXScxoOVdWpvN63qQwjDdSx3dr1IZ2CuSLX9V+J9Tg+SRrUHI5/\nULOkKvbsNZ5EfTapJEmSJEmSJEmSJEmSJEmSpNb5f+4oC/CW12rBAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d737b10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "def plot_resampled_stats(n=100):\n",
    "    sample = weight.rvs(n)\n",
    "    resampler = StdResampler(sample, xlim=[0, 100])\n",
    "    resampler.plot_sample_stats()\n",
    "    \n",
    "plot_resampled_stats()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When your `StdResampler` is working, you should be able to interact with it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 1.29095098626\n",
      "90% CI [ 15.13442137  19.27452588]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEPCAYAAACjjWTcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEfVJREFUeJzt3XuMnNV9h/FnWNsk4GDvitZ3YteYCkNbII1LSyomluMa\nNcWENlxSWrelERJpoOkFMFLDboIIiQKhN1AbLnIhuHHAcY2iUAxmKtIEyMUGlsXBdrCKXbymgBOo\n2sYs2z/OGe94r7Mzszvr/T0f6dW875n3fefsgfnO8XlvIEmSJEmSJEmSJEmSJEmSpAZ5F/AUsB3o\nAj6Xy9uALcCLwCPAzIpt1gI7gR3AynGrqSSpLsfl1ynAk8AHgC8A1+Tya4Gb8/xS0g/DVGAhsAs4\nZrwqKkmq33HAd4HTSL32Wbl8dl6G1Ku/tmKbh4Gzx6uCkqTBVdPrPobUW+8GHgeeJwV9d36/m77g\nnwvsrdh2LzCvITWVJNVsShXrvAOcAcwA/hX4YL/3e/M0lOHekySNg2rCvuzHwDeA95F687OB/cAc\n4EBeZx+woGKb+bnsCIsXL+7dvXt3LfWVpMh2AyfXsuFIwzgn0nemzbuBDwHbgM3Amly+BtiU5zcD\nlwDTgEXAEuDpAbXdvZve3l6n3l5uuOGGptdhoky2hW1hWww/AYtrCXoYuWc/B1hH+lE4BrgXeCwH\n/gbgcmAPcFFevyuXdwFvA1fiMI4kNd1IYf8ccNYg5a8DK4bY5qY8SZImCM+Bb7JisdjsKkw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ePQt5PifQQkRm5Pm8C76lY7wTScBLA\nH1SU919vtPstr/sWaSy/PIxzLA7jqA6GvZrhF0jj0dtIB2VvBH5M6s13kp6n+dQQ2w53Zs0PgU+Q\nDtDOAO7o9/5/kYJ5Pekg6beBn++3TgvpQSrPkg6+/nWu20PARzjyQOrXSM9peLWiTuX1fkDfMFJv\nFfvtvz6kUzCvynX9d2I9jk+SBrWQIx/ULKmCPXtNJlGfTSpJkiRJkiRJkiRJkiRJkiSpcf4fQI9Q\ndtjHGXsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d78d110>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "slider = widgets.IntSliderWidget(min=10, max=1000, value=100)\n",
    "interact(plot_resampled_stats, n=slider)\n",
    "None"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Part Three\n",
    "==========\n",
    "\n",
    "We can extend this framework to compute SE and CI for a difference in means.\n",
    "\n",
    "For example, men are heavier than women on average.  Here's the women's distribution again (from BRFSS data):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(72.697645732966876, 16.944043048498038)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "female_weight = scipy.stats.lognorm(0.23, 0, 70.8)\n",
    "female_weight.mean(), female_weight.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's the men's distribution:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(89.063576984335782, 17.992335889366288)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "male_weight = scipy.stats.lognorm(0.20, 0, 87.3)\n",
    "male_weight.mean(), male_weight.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "I'll simulate a sample of 100 men and 100 women:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "female_sample = female_weight.rvs(100)\n",
    "male_sample = male_weight.rvs(100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The difference in means should be about 17 kg, but will vary from one random sample to the next:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15.521337537414979"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "male_sample.mean() - female_sample.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's the function that computes Cohen's $d$ again:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def CohenEffectSize(group1, group2):\n",
    "    \"\"\"Compute Cohen's d.\n",
    "\n",
    "    group1: Series or NumPy array\n",
    "    group2: Series or NumPy array\n",
    "\n",
    "    returns: float\n",
    "    \"\"\"\n",
    "    diff = group1.mean() - group2.mean()\n",
    "\n",
    "    n1, n2 = len(group1), len(group2)\n",
    "    var1 = group1.var()\n",
    "    var2 = group2.var()\n",
    "\n",
    "    pooled_var = (n1 * var1 + n2 * var2) / (n1 + n2)\n",
    "    d = diff / numpy.sqrt(pooled_var)\n",
    "    return d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The difference in weight between men and women is about 1 standard deviation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9271315108152719"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "CohenEffectSize(male_sample, female_sample)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can write a version of the `Resampler` that computes the sampling distribution of $d$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "class CohenResampler(Resampler):\n",
    "    def __init__(self, group1, group2, xlim=None):\n",
    "        self.group1 = group1\n",
    "        self.group2 = group2\n",
    "        self.xlim = xlim\n",
    "        \n",
    "    def resample(self):\n",
    "        group1 = numpy.random.choice(self.group1, len(self.group1), replace=True)\n",
    "        group2 = numpy.random.choice(self.group2, len(self.group2), replace=True)\n",
    "        return group1, group2\n",
    "    \n",
    "    def sample_stat(self, groups):\n",
    "        group1, group2 = groups\n",
    "        return CohenEffectSize(group1, group2)\n",
    "    \n",
    "    # NOTE: The following functions are the same as the ones in Resampler,\n",
    "    # so I could just inherit them, but I'm including them for readability\n",
    "    def compute_sample_statistics(self, iters=1000):\n",
    "        stats = [self.sample_stat(self.resample()) for i in range(iters)]\n",
    "        return numpy.array(stats)\n",
    "    \n",
    "    def plot_sample_stats(self):\n",
    "        sample_stats = self.compute_sample_statistics()\n",
    "        summarize_sampling_distribution(sample_stats)\n",
    "        pyplot.hist(sample_stats, color=COLOR2)\n",
    "        pyplot.xlabel('sample statistic')\n",
    "        pyplot.xlim(self.xlim)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we can instantiate a `CohenResampler` and plot the sampling distribution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SE 0.160707033098\n",
      "90% CI [ 0.6808076  1.1974013]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEPCAYAAACneLThAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEkZJREF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\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f294d796fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "resampler = CohenResampler(male_sample, female_sample)\n",
    "resampler.plot_sample_stats()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example demonstrates an advantage of the computational framework over mathematical analysis.  Statistics like Cohen's $d$, which is the ratio of other statistics, are relatively difficult to analyze.  But with a computational approach, all sample statistics are equally \"easy\".\n",
    "\n",
    "One note on vocabulary: what I am calling \"resampling\" here is a specific kind of resampling called \"bootstrapping\".  Other techniques that are also considering resampling include permutation tests, which we'll see in the next section, and \"jackknife\" resampling.  You can read more at <http://en.wikipedia.org/wiki/Resampling_(statistics)>."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
